package model.fabrica;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import model.classesDAO.FabricanteDAO;
import model.classesDAO.ModeloDAO;

public abstract class Fabrica {
	
	private static EntityManager em;
	private static final EntityManagerFactory emf;
	
	static{
		
		emf = Persistence.createEntityManagerFactory("af-final");
		
		if (em == null){
			
			em = emf.createEntityManager();
		}
		
	}
	
	public static FabricanteDAO getFabricanteDAO(){
		FabricanteDAO fabricanteDAO = new FabricanteDAO();
		fabricanteDAO.setEntityManager(em);
		return fabricanteDAO;
	}
	
	public static ModeloDAO getModeloDAO(){
		ModeloDAO modeloDAO= new ModeloDAO();
		modeloDAO.setEntityManager(em);
		return modeloDAO;
    }
	
	
}
